package com.ruoyi.parkingcar.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.parkingcar.domain.Esmap;
import com.ruoyi.parkingcar.service.IEsmapService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 停车场地图Controller
 * 
 * @author 饼干
 * @date 2025-02-16
 */
@RestController
@RequestMapping("/parkingcar/esmap")
public class EsmapController extends BaseController
{
    @Autowired
    private IEsmapService esmapService;

    /**
     * 查询停车场地图列表
     */
    @PreAuthorize("@ss.hasPermi('parkingcar:esmap:list')")
    @GetMapping("/list")
    public TableDataInfo list(Esmap esmap)
    {
        startPage();
        List<Esmap> list = esmapService.selectEsmapList(esmap);
        return getDataTable(list);
    }

    /**
     * 导出停车场地图列表
     */
    @PreAuthorize("@ss.hasPermi('parkingcar:esmap:export')")
    @Log(title = "停车场地图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Esmap esmap)
    {
        List<Esmap> list = esmapService.selectEsmapList(esmap);
        ExcelUtil<Esmap> util = new ExcelUtil<Esmap>(Esmap.class);
        util.exportExcel(response, list, "停车场地图数据");
    }

    /**
     * 获取停车场地图详细信息
     */
    @PreAuthorize("@ss.hasPermi('parkingcar:esmap:query')")
    @GetMapping(value = "/{slotId}")
    public AjaxResult getInfo(@PathVariable("slotId") Long slotId)
    {
        return success(esmapService.selectEsmapBySlotId(slotId));
    }

    /**
     * 新增停车场地图
     */
    @PreAuthorize("@ss.hasPermi('parkingcar:esmap:add')")
    @Log(title = "停车场地图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Esmap esmap)
    {
        return toAjax(esmapService.insertEsmap(esmap));
    }

    /**
     * 修改停车场地图
     */
    @PreAuthorize("@ss.hasPermi('parkingcar:esmap:edit')")
    @Log(title = "停车场地图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Esmap esmap)
    {
        return toAjax(esmapService.updateEsmap(esmap));
    }

    /**
     * 删除停车场地图
     */
    @PreAuthorize("@ss.hasPermi('parkingcar:esmap:remove')")
    @Log(title = "停车场地图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{slotIds}")
    public AjaxResult remove(@PathVariable Long[] slotIds)
    {
        return toAjax(esmapService.deleteEsmapBySlotIds(slotIds));
    }

    @GetMapping("/NoCar")
    public AjaxResult Nocar(){

        return AjaxResult.success(esmapService.selectNoCar());
    }


    @GetMapping("/HaveCar")
    public AjaxResult Havecar(){

        return AjaxResult.success(esmapService.selectHaveCar());
    }

    @GetMapping("/esmapList")
    public AjaxResult esmapList(Esmap esmap){
        List<Esmap> list = esmapService.EsmapList(esmap);
        return AjaxResult.success(list);
    }
}
